package com.dongnao.jack.spring.parse;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.dongnao.jack.registry.handler.JedisServiceRegistryHandler;
import com.dongnao.jack.registry.handler.ServiceRegistryHandler;

/**
 * 
 * @ClassName: RegistryConfig 
 * @Description:记录数据存放的地址(也就是 spring对象存放的中间缓存 如zookeeper/redis)
 * @author xuyp
 * @date 2018年4月17日 下午2:00:18 
 *
 */
public class RegistryConfig implements Serializable {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -7703954990829686253L;

    /**
     * 服务注册的协议 如redis/zookeeper
     */
    private String protocol;

    /**
     * 服务注册的地址
     */
    private String address;

    private static Map<String, ServiceRegistryHandler> serviceMap = new HashMap<>();
    static {
        serviceMap.put("redis", new JedisServiceRegistryHandler());
        serviceMap.put("zookeeper", null);
    }

    public static Map<String, ServiceRegistryHandler> getServiceMap() {
        return serviceMap;
    }

    public static void setServiceMap(Map<String, ServiceRegistryHandler> serviceMap) {
        RegistryConfig.serviceMap = serviceMap;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "RegistryConfig [protocol=" + protocol + ", address=" + address + "]";
    }

}
